package com.yfqy.admin.util;

import com.yfqy.admin.security.login.LoginUserInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class AuthUserContext {

    private static final Logger log = LoggerFactory.getLogger(AuthUserContext.class);

    protected static final ThreadLocal<LoginUserInfo> USER_INFO_THREAD_LOCAL = new ThreadLocal<LoginUserInfo>();

    public static void clearLocalAuthUser() {
//        log.info("AuthUserContextFilter已清除当前线程的用户信息{}",USER_INFO_THREAD_LOCAL.get());
        USER_INFO_THREAD_LOCAL.remove();
    }

    public static void setLocalAuthUser(LoginUserInfo loginUserInfo) {
//        log.info("AuthUserContextFilter已缓存当前线程的用户信息{}", loginUserInfo);
        USER_INFO_THREAD_LOCAL.set(loginUserInfo);
    }

    public static LoginUserInfo getLocalAuthUser() {
        return USER_INFO_THREAD_LOCAL.get();
    }
}
